package com.cn.thread.disruptor.multi;

import com.cn.thread.disruptor.domain.Trade;
import com.lmax.disruptor.RingBuffer;

public class ProduceMulti {

    private RingBuffer<Trade> ringBuffer;

    public ProduceMulti(RingBuffer<Trade> ringBuffer) {
        this.ringBuffer = ringBuffer;
    }

    public void sendData(String uuid) {
        long sequence = ringBuffer.next();
        try {
            Trade order = ringBuffer.get(sequence);
            order.setId(uuid);
        } finally {
            ringBuffer.publish(sequence);
        }
    }
}
